package com.feather.unit;

import java.io.StringReader;
import java.io.StringWriter;
import java.util.Map;
import com.feather.annotation.*;

import freemarker.template.Template;


public class FreemarkerActionUnit {

	@ActionMethod
	public Object formatString(
			@InputParam(name="template") String template,
			@InputParam(name="params") Map<String, Object> params) throws Exception
	{
		Template freemarkerTemplate = new Template(String.valueOf(template.hashCode()), new StringReader(template), null);
		StringWriter out = new StringWriter();
		freemarkerTemplate.process(params, out);
		return out.toString();
	}
}
